//
//  AlertControllerHelper.m
//  CedarFinancePH
//
//  Created by lshenrong on 2018/4/6.
//  Copyright © 2018年 cedarhd. All rights reserved.
//

#import "AlertControllerHelper.h"

@implementation AlertControllerHelper


+ (UIAlertController *)callPhoneWithContent:(NSString *)content handler:(void (^)(void))handelr{
    NSString *tips = @"提示";
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:tips message:content preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"立即呼叫" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if(handelr){
            handelr();
        }
    }]];
    return alert;
}

+ (TYAlertController *)TYAlertControllerWithView:(UIView *)view{
    TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:view preferredStyle:TYAlertControllerStyleAlert transitionAnimation:TYAlertTransitionAnimationFade];
    alertController.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
    alertController.backgoundTapDismissEnable = NO;
    return alertController;
}


+ (TYAlertController *)TYAlertControllerWithStyleActionSheet:(UIView *)view{
    TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:view preferredStyle:TYAlertControllerStyleActionSheet transitionAnimation:TYAlertTransitionAnimationFade];
    alertController.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
    alertController.backgoundTapDismissEnable = NO;
    return alertController;
}



+ (UIAlertController *)alertWithTitle:(NSString *)title
                              content:(NSString *)content
                           leftActionTitle:(NSString *)leftTitle
                           rightActionTitle:(NSString *)rightTitle
                              leftHandler:(void (^)(void))leftHanlder
                              rightHandler:(void (^)(void))rightHanlder{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:content preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:[UIAlertAction actionWithTitle:leftTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if(leftHanlder){
            leftHanlder();
        }
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:rightTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if(rightHanlder){
            rightHanlder();
        }
    }]];
    return alert;
}


@end
